package com.auto.learning.tools;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Stack;

import android.app.Activity;

import com.auto.learning.MainActivity;
import com.auto.learning.bean.BreakPointBean;
import com.auto.learning.event.BookMoneyEvent;
/**
 * 迫不得已的全局变量
 * @author wangjianjun
 */
public class TemporaryVariable {

	public static ArrayList<Integer> downLoadedList = new ArrayList<Integer>();  //下载到本地列表--bookId
	
	public static ArrayList<Integer> temp_download_all_list = new ArrayList<Integer>();  //报存临时要下载的列表--bookId
	
	public static ArrayList<Integer> read_list = new ArrayList<Integer>();  //阅读下一本书的列表 -- bookId
	
	public static Activity activity = null;  //锁屏的activity
	
	public static Activity playActivity = null; // 播放页面
	
	public static Stack<Activity> activities = new Stack<Activity>();    //页面中activity管理
	
	public static Map<Integer, BreakPointBean> breakPiontMap = new LinkedHashMap<Integer, BreakPointBean>();
	
	public static BookMoneyEvent bookmoney = new BookMoneyEvent();
	
	/**
	 * 取上一个
	 * @return
	 */
	public static Activity getTopActivity() {
		Activity _activity = null;
		if (!activities.isEmpty()) {
			_activity = activities.pop();
			if (_activity != null) {
				activities.push(_activity);
			}
		}
		return _activity;
	}
	
	/**
	 * 回到首页
	 */
	public static void gotoHome(){
		if (!activities.isEmpty()) {
			Activity mActivity = activities.pop();
			if (mActivity != null) {
				if (mActivity instanceof MainActivity) {
					activities.push(mActivity);
				}else {
					mActivity.finish();
					gotoHome();
				}
			}
		}
	}
	
}
